package edu.cmu.vlis.wassup.tests;

import edu.cmu.vlis.wassup.publisher.UpcomingPoller;
import edu.cmu.vlis.wassup.publisher.UserEventPoller;
import edu.cmu.vlis.wassup.sender.MessageProcessor;
class Thread1 extends Thread{

		UpcomingPoller poller ;
		Thread1()  {
			poller = new UpcomingPoller(12000);
		}

		public void run() {
			poller.start("U");
		}
		
		public void restart() {
			poller.start("u");
		}

		public void pause() {
			poller.stop();
		}
		
		public void destroy() {
			poller.shutDown();
		}
	}
	
	class Thread3 extends Thread{

		UserEventPoller upoller ;
		Thread3()  {
			upoller = new UserEventPoller(11100);
		}

		public void run() {
			upoller.start("u");
		}
		
		/*public void restart() {
			poller.start();
		}

		public void pause() {
			poller.stop();
		}
		
		public void destroy() {
			poller.shutDown();
		}*/
	}

	class Thread2 extends Thread{

		MessageProcessor s;
		Thread2()  {
			 s = new MessageProcessor(30000);
		}

		public void run() {
			s.start("music");
		}
		
		public void pause() {
			s.stopMP();
		}
		
		public void destroy() {
			s.shutDown();
		}
	}

	public class whatsupTester {

	public static void main(String[] args) {
		
		Thread2 th2 = new Thread2();
		th2.start();
		
		//Test Upcoming
		Thread1 th = new Thread1();
		th.start();
		System.out.println(" i am stoping poller");
        th.pause();
		
        //Text userevent
/*		Thread3 th3 = new Thread3();
		th3.start();*/
		
		
        
        try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		/*System.out.println(" i am stoping poller");
        th.pause();
        
        try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
        System.out.println("i am restarting poller");
        th.run();*/
        
        
/*		//For destroying the poller.
		System.out.println("i am ending the poller");
        th.destroy();*/
        
//		System.out.println(" i am stoping Processor!");
//		th2.pause();
//		
//		try {
//			Thread.sleep(20000);
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		/* System.out.println("i am restarting Processor");
//		th2.run();*/
//		
//		//Checking destory test case
//		th2.destroy();
        
	}
}
